package com.example.dao;

import com.example.entity.StudentInfo;
import com.example.entity.XueYuanInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author 涛某
 * @version 1.0
 * @date 2024/3/24 11:53
 */
@Repository
public interface XueyuanInfoDao extends Mapper<XueYuanInfo> {

    @Select("select * from xueyuan")
    List<XueYuanInfo> findAll();

    @Insert("insert into xueyuan(name,description,score) values(#{name},#{description},#{score})")
    void add(XueYuanInfo xueYuanInfo);


    @Select("select * from xueyuan where name = #{name}")
    XueYuanInfo findByName(@Param("name") String name);

    @Delete("delete from xueyuan where id = #{id}")
    Long deleteById(@Param("id") Long id);

    @Update("update xueyuan set name=#{name},description=#{description},score=#{score} where id = #{id}")
    void update(XueYuanInfo xueYuanInfo);

    @Select("select * from xueyuan where name like concat('%',#{search},'%') or description like concat('%',#{search},'%') or score like concat('%',#{search},'%') ")
    List<XueYuanInfo> findPageByname(@Param("search") String search);


    @Select("select * from xueyuan where id = #{xueyuanid}")
    XueYuanInfo findById(Long xueyuanid);

}

